home *** CD-ROM | disk | FTP | other *** search
- // NewProj.cpp : implementation file
- //
-
- // pour lecture dir
- //#include "kernel32.h"
-
- #include "stdafx.h"
- #include "Shell.h"
- #include "NewProj.h"
-
- /* Externe C */
- extern "C" {
- #include "htscore.h"
- }
-
- #include "XSHBrowseForFolder.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- extern HICON httrack_icon;
- extern CNewProj* dialog0;
-
- // Helper
- extern LaunchHelp* HtsHelper;
-
- /* Main WizTab frame */
- #include "WizTab.h"
- extern CWizTab* this_CWizTab;
-
- /* Main splitter frame */
- #include "DialogContainer.h"
- #include "splitter.h"
- extern CSplitterFrame* this_CSplitterFrame;
-
- /* DirTreeView */
- #include "DirTreeView.h"
- extern CDirTreeView* this_DirTreeView;
-
- /* reference sur objet Wid1 */
- #include "Wid1.h"
- extern Wid1* dialog1;
-
- /* shellapp */
- extern CShellApp* CShellApp_app;
-
- /* crÈation structure */
- extern "C" HTSEXT_API int structcheck(char* s);
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CNewProj dialog
-
- IMPLEMENT_DYNCREATE(CNewProj, CPropertyPage)
-
- CNewProj::CNewProj()
- : CPropertyPage(CNewProj::IDD)
- {
- dialog0=this; /* NOTER REFERENCE */
- can_click_next=TRUE;
- //{{AFX_DATA_INIT(CNewProj)
- m_projname = _T("");
- m_projpath = _T("");
- //}}AFX_DATA_INIT
- }
-
- CNewProj::~CNewProj() {
- dialog0=NULL;
- }
-
-
- void CNewProj::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CNewProj)
- DDX_Control(pDX, IDC_projname, m_ctl_projname);
- DDX_Text(pDX, IDC_projname, m_projname);
- DDX_Text(pDX, IDC_projpath, m_projpath);
- //}}AFX_DATA_MAP
- }
-
-
- #define wm_CEasyDropTargetCallback (WM_USER + 1)
- BEGIN_MESSAGE_MAP(CNewProj, CPropertyPage)
- //{{AFX_MSG_MAP(CNewProj)
- ON_BN_CLICKED(IDC_br, Onbr)
- ON_EN_CHANGE(IDC_projpath, OnChangeprojpath)
- ON_CBN_EDITCHANGE(IDC_projname, OnChangeprojname)
- ON_WM_CREATE()
- ON_CBN_SELCHANGE(IDC_projname, OnSelchangeprojname)
- //}}AFX_MSG_MAP
- ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
- ON_COMMAND(ID_HELP,OnHelpInfo2)
- ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
- ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
- //
- ON_MESSAGE( wm_CEasyDropTargetCallback, DragDropText)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CNewProj message handlers
-
- CString CNewProj::GetBasePath() {
- CString st=m_projpath;
- st.Replace('/','\\');
- st+="\\";
- return st;
- }
-
- CString CNewProj::GetName() {
- return m_projname;
- }
-
- CString CNewProj::GetPath0() {
- CString st=m_projpath;
- st.Replace('/','\\');
- st+="\\";
- st+=m_projname;
- return st;
- }
-
- CString CNewProj::GetPath() {
- CString st=GetPath0();
- st+="\\";
- return st;
- }
-
- LRESULT CNewProj::OnWizardNext() {
- CString st,stp="";
- char tempo[8192];
-
- GetDlgItemText(IDC_projpath,stp);
- strcpybuff(tempo,stp);
- if ((tempo[strlen(tempo)-1]=='/') || (tempo[strlen(tempo)-1]=='\\'))
- tempo[strlen(tempo)-1]='\0';
- stp=tempo;
-
- // ecrire
- CString strSection = "DefaultValues";
- CWinApp* pApp = AfxGetApp();
- pApp->WriteProfileString(strSection,"BasePath",stp);
-
- GetDlgItemText(IDC_projname,st);
- strcpybuff(tempo,st);
- // caractËres interdits
- {
- int i;
- char* a=NULL;
- for(i=0;i<9;i++)
- while(a=strchr(tempo,("\\/:*?\"<>|")[i]))
- *a=' ';
- }
- //
- //while(a=strchr(tempo,' ')) *a='_'; // PAS de _
- SetDlgItemText(IDC_projname,tempo);
-
- // ModifiÈ et sauvable
- GetDlgItemText(IDC_projpath,stp);
- if ((stp.Right(1)!="\\") && (stp.Right(1)!="/")) // ajouter /
- stp+="\\";
- GetDlgItemText(IDC_projname,st);
- this_CSplitterFrame->SetNewName(stp+st+".whtt");
- //GetDlgItemText(IDC_projpath,st);
- //this_CSplitterFrame->GetActiveDocument()->SetPathName(st);
-
- if (can_click_next)
- return 0;
- else
- return -1;
- }
-
- void CNewProj::Onbr()
- {
- CString st,spth;
- char pth[256];
- GetDlgItemText(IDC_projpath,spth);
- strcpybuff(pth,spth);
- st=XSHBrowseForFolder(this->m_hWnd,"Select a path name for mirror",pth);
- if (st.GetLength()>0) {
- if (st.Right(1)=='\\')
- st=st.Left(st.GetLength()-1);
- SetDlgItemText(IDC_projpath,st);
- }
-
- }
-
- BOOL CNewProj::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
- SetIcon(httrack_icon,false);
- SetIcon(httrack_icon,true);
- EnableToolTips(true); // TOOL TIPS
- SetForegroundWindow(); // yop en premier plan!
-
- // disabled
- OnChangeprojname();
-
- // Patcher l'interface pour les FranÁais ;-)
- if (LANG_T(-1)) { // Patcher en franÁais
- SetWindowText( LANG(LANG_S10));
- // SetDlgItemText(IDOK,LANG(LANG_NEXT )); // "SUIVANT ->");
- // SetDlgItemText(IDCANCEL,LANG(LANG_QUIT)); // exit
- SetDlgItemText(IDC_STATIC_projname,LANG(LANG_S11));
- SetDlgItemText(IDC_STATIC_basepath,LANG(LANG_S12));
- //SetDlgItemText(IDC_STATIC_updtcontinue,LANG(LANG_S13));
- }
-
- CString strSection = "DefaultValues";
- CWinApp* pApp = AfxGetApp();
- CString st;
-
- st = pApp->GetProfileString(strSection, "BasePath");
- if (m_projpath.GetLength()==0) {
- if (st != "")
- SetDlgItemText(IDC_projpath,st);
- else
- SetDlgItemText(IDC_projpath,LANG(LANG_S20));
- }
-
- return TRUE;
- }
-
- void CNewProj::OnChangeprojpath()
- {
- CWaitCursor wait;
- CString st;
- CString old_name;
- char tempo[HTS_URLMAXSIZE*2];
-
- GetDlgItemText(IDC_projname,old_name);
- GetDlgItemText(IDC_projpath,st);
- strcpybuff(tempo,st);
- if ((tempo[strlen(tempo)-1]=='/') || (tempo[strlen(tempo)-1]=='\\')) {
- tempo[strlen(tempo)-1]='\0';
- //SetDlgItemText(IDC_projpath,tempo);
- }
- strcatbuff(tempo,"\\");
-
- // chargement de la liste
- m_ctl_projname.ResetContent();
- WIN32_FIND_DATA find;
- char pth[MAX_PATH + 32];
- strcpybuff(pth,tempo);
- strcatbuff(pth,"*.*");
- HANDLE h = FindFirstFile(pth,&find);
- if (h != INVALID_HANDLE_VALUE) {
- do {
- if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
- if (!(find.dwFileAttributes & (FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN) ))
- if (strcmp(find.cFileName,".."))
- if (strcmp(find.cFileName,".")) {
- CString st;
- st=tempo;
- st=st+find.cFileName;
- st=st+"\\hts-cache";
-
- WIN32_FIND_DATA find2;
- HANDLE h2 = FindFirstFile(st,&find2);
- if (h2 != INVALID_HANDLE_VALUE) {
- FindClose(h2);
- m_ctl_projname.InsertString(-1,find.cFileName);
- }
- }
- } while(FindNextFile(h,&find));
- FindClose(h);
- }
-
- // nouveau nom!
- SetDlgItemText(IDC_projname,old_name);
- OnChangeprojname();
- }
-
-
-
- // ------------------------------------------------------------
- // TOOL TIPS
- //
- // ajouter dans le .cpp:
- // remplacer les deux Wid1:: par le nom de la classe::
- // dans la message map, ajouter
- // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
- // dans initdialog ajouter
- // EnableToolTips(true); // TOOL TIPS
- //
- // ajouter dans le .h:
- // char* GetTip(int id);
- // et en generated message map
- // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
- BOOL CNewProj::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
- {
- TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
- UINT nID =pNMHDR->idFrom;
- if (pTTT->uFlags & TTF_IDISHWND)
- {
- // idFrom is actually the HWND of the tool
- nID = ::GetDlgCtrlID((HWND)nID);
- if(nID)
- {
- char* st=GetTip(nID);
- if (st != "") {
- pTTT->lpszText = st;
- pTTT->hinst = AfxGetResourceHandle();
- return(TRUE);
- }
- }
- }
- return(FALSE);
- }
- char* CNewProj::GetTip(int ID)
- {
- switch(ID) {
- case IDC_projname: return LANG(LANG_S1); break;
- case IDC_projpath: return LANG(LANG_S2); break;
- //case IDC_projlist: return LANG(LANG_S3); break;
- case IDC_br: return LANG(LANG_S4); break;
- case IDCANCEL: return LANG(LANG_G20); break; // "Quit WinHTTrack","Quittter WinHTTrack"); break;
- case IDOK: return LANG(LANG_G23); break; // "Click to continue","Clic pour continuer"); break;
- }
- return "";
- }
- // TOOL TIPS
- // ------------------------------------------------------------
-
-
- void CNewProj::OnChangeprojname()
- {
- CString stl;
- GetDlgItemText(IDC_projname,stl);
- Changeprojname(stl);
- }
-
- void CNewProj::Changeprojname(CString stl) {
- CWaitCursor wait;
- CString st;
- //
- if (stl.GetLength()==0) {
- //m_ctl_idok.ModifyStyle(0,WS_DISABLED);
- SetDlgItemText(IDC_STATIC_comments,LANG(LANG_S30));
- SetDlgItemText(IDC_STATIC_projname,LANG(LANG_S11c));
- this_CWizTab->SetWizardButtons(PSWIZB_BACK);
- can_click_next=FALSE;
- } else {
- char tempo[HTS_URLMAXSIZE*2];
- GetDlgItemText(IDC_projpath,st);
- strcpybuff(tempo,st);
- strcatbuff(tempo,"/");
- strcatbuff(tempo,stl);
- strcatbuff(tempo,"/");
- if (fexist(fconcat(tempo,"hts-cache/winprofile.ini"))) { // un cache est prÈsent
- if (fsize(fconcat(tempo,"hts-cache/winprofile.ini"))>0) { // taille log contrÙle>0
- CString strSection = "OptionsValues";
- CString st = MyGetProfileString(fconcat(tempo,"hts-cache/winprofile.ini"),strSection,"CurrentUrl");
- //
- SetDlgItemText(IDC_STATIC_comments,st);
- SetDlgItemText(IDC_STATIC_projname,LANG(LANG_S11b));
- } else {
- SetDlgItemText(IDC_STATIC_comments,LANG(LANG_S31));
- SetDlgItemText(IDC_STATIC_projname,LANG(LANG_S11));
- }
- } else {
- SetDlgItemText(IDC_STATIC_comments,LANG(LANG_S31));
- SetDlgItemText(IDC_STATIC_projname,LANG(LANG_S11));
- }
- //m_ctl_idok.ModifyStyle(WS_DISABLED,0);
- //if (!can_click_next)
- this_CWizTab->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);
- can_click_next=TRUE;
- }
- //m_ctl_idok.RedrawWindow();
- }
-
-
- // help
- // Appel aide
- BOOL CNewProj::OnHelpInfo2() {
- return OnHelpInfo(NULL);
- }
-
- BOOL CNewProj::OnHelpInfo(HELPINFO* dummy)
- {
- //return CPropertyPage::OnHelpInfo(pHelpInfo);
- //AfxGetApp()->WinHelp(0,HELP_FINDER); // Index du fichier Hlp
- HtsHelper->Help("step1.html");
- //HtsHelper->Help();
- return true;
- }
-
-
- extern HWND App_Main_HWND;
- int CNewProj::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- //lpCreateStruct->hwndParent=AfxGetApp()->GetMainWnd()->m_hWnd;
- lpCreateStruct->hwndParent=App_Main_HWND;
- if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- // Drag&Drop
- drag=new CEasyDropTarget(this);
- if (drag->IsRegistered()) {
- drag->SetTextCallback(wm_CEasyDropTargetCallback);
- }
-
- return 0;
- }
-
- // Message from CEasyDropTarget
- LRESULT CNewProj::DragDropText(WPARAM wParam,LPARAM lParam) {
- if (lParam) {
- CString st=*((CString*) lParam);
- CLIPFORMAT cfFormat=wParam;
- if (cfFormat==CF_HDROP) {
- if (st.Right(5).CompareNoCase(".whtt")==0)
- st=st.Left(st.GetLength()-5);
- if(st.GetLength()<256) {
- char s[256];
- strcpybuff(s,st);
- if (!fexist(s)) {
- if (st.Find('\n')<0) {
- int pos=st.ReverseFind('\\');
- SetDlgItemText(IDC_projpath,st.Mid(0,pos));
- SetDlgItemText(IDC_projname,st.Mid(pos+1));
- //
- OnChangeprojpath();
- OnChangeprojname();
- } else
- AfxMessageBox(LANG(LANG_DIAL3),MB_SYSTEMMODAL);
- } else
- AfxMessageBox(LANG(LANG_DIAL4),MB_SYSTEMMODAL);
- }
- } else
- AfxMessageBox(LANG(LANG_DIAL5),MB_SYSTEMMODAL);
- }
- return 0;
- }
-
-
- void CNewProj::OnSelchangeprojname()
- {
- CString stl;
- int r;
- if ((r=m_ctl_projname.GetCurSel()) != CB_ERR) {
- m_ctl_projname.GetLBText(r,stl);
- } else
- GetDlgItemText(IDC_projname,stl);
- Changeprojname(stl);
- }
-
- BOOL CNewProj::OnSetActive( ) {
- //this_CWizTab->SetWizardButtons(PSWIZB_BACK);
-
- WHTT_LOCATION("NewProj");
- //if (!can_click_next) {
- // structure visible
- CString st;
- GetDlgItemText(IDC_projpath,st);
- this_DirTreeView->EnsureVisible(st+"\\index.html");
- this_CWizTab->SetDlgItemText(IDCANCEL,LANG_CANCEL);
- //} else
- //this_CWizTab->PressButton(PSBTN_NEXT);
-
- return 1;
- }
-
- BOOL CNewProj::OnQueryCancel( ) {
- this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
- return 0;
- }
-
- BOOL CNewProj::OnKillActive( ) {
- CString st;
- char tempo[HTS_URLMAXSIZE*2];
- GetDlgItemText(IDC_projpath,st);
- strcpybuff(tempo,st);
- if ((tempo[strlen(tempo)-1]=='/') || (tempo[strlen(tempo)-1]=='\\')) {
- tempo[strlen(tempo)-1]='\0';
- SetDlgItemText(IDC_projpath,tempo);
- }
-
- UpdateData(TRUE); // DoDataExchange
-
- // crÈer structure
- {
- char dest[HTS_URLMAXSIZE*2];
- int i=0;
- strcpybuff(dest,GetPath()+"hts-cache\\");
- {
- char* a;
- while(a=strchr(dest,'\\')) *a='/';
- structcheck(dest);
- }
- }
-
- CShellApp_app->end_path=dialog0->GetBasePath();
- CShellApp_app->end_path_complete=dialog0->GetPath();
- Build_TopIndex(FALSE);
-
- // structure visible
- this_DirTreeView->EnsureVisible(GetPath()+"hts-cache");
-
- // charger prÈfs
- dialog1->OnChangepathlog();
-
- return 1;
- }
-
-
-